package main

import (
	"context"
	global "developer_tools/globals"
	"developer_tools/internal/share"
)

var _shareContent = share.NewShareContent()

type ShareApp struct {
	ctx context.Context
}

func NewShareApp() *ShareApp {
	return &ShareApp{}
}

func (a *ShareApp) startup(ctx context.Context) {
	a.ctx = ctx
}

func (a *ShareApp) shutdown() {
	log_.Info("[ShareApp]Shutting down...")
}

func (a *ShareApp) Share(content []byte, command string) string {
	// 1. Create a temporary file with the provided content.
	createFile := _shareContent.CreateTmpFile(content)
	if !createFile {
		return global.FailedToCreateTmpFile
	}
	// 2. If successful, execute the share command using the temporary file.
	switch command {
	case "localcode.share":
		return _shareContent.DoLocalCodeShare()
	default:
		return global.UnsupportedShareCommand
	}
}
